﻿@inject ICategoryService _categoryService


<div class="top-row ps-3 navbar navbar-dark navbar-toggler-wrapper">
    <div class="container-fluid">        
        <button title="Navigation menu" class="navbar-toggler" @onclick="ToggleNavMenu">
            <span class="navbar-toggler-icon"></span>
        </button>
    </div>
</div>

<div class="@NavMenuCssClass" @onclick="ToggleNavMenu">
    <nav class="flex-nav">
        <div class="nav-item px-2">
            <NavLink class="nav-link" href="" Match="NavLinkMatch.All">
                Home
            </NavLink>
        </div>

        @foreach (var category in _categoryService .Categories)
        {
            <div class="nav-item px-2">
                <NavLink class="nav-link"  href="@category.Url">
                    @category.Name
                </NavLink>
            </div>
        }

    </nav>
</div>

@code {
    private bool collapseNavMenu = true;

    private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null;

    private void ToggleNavMenu()
    {
        collapseNavMenu = !collapseNavMenu;
    }

    protected override async Task OnInitializedAsync()
    {
        await _categoryService.GetCategories();
    }






}
